/*
Date:20210425 18:20PM
key:拿一个vector中序遍历跟着装元素即可
 */
class Solution {
public:
    void change(TreeNode* root,vector<int> &v)
    {
        if(root!=nullptr)
        {
            change(root->left,v);
            //cout<<root->val;
            v.push_back(root->val);
            change(root->right,v);
        }
        else
        {
            return ;
        }
    }
    TreeNode* increasingBST(TreeNode* root) 
    {
        vector<int> v;
        TreeNode* newhead=new TreeNode;
        TreeNode* p=newhead;
        change(root,v);
        for(int j=0;j<v.size();j++)
        {
            p->val=v[j];
            if(j!=v.size()-1)
            {
                p->right=new TreeNode;
                p=p->right;
            }
            
        }
        return newhead;
    }
};